class Animal {
  constructor(name) {
    //   构造函数是实例化之后执行的逻辑
    this.name = name;
  }

  run() {
    return `${this.name} is running`;
  }
}

const snake = new Animal("lily");
console.log(snake.run());

// 类的继承
class Dog extends Animal {
  bark() {
    return `${this.name} is barking`;
  }
}

const xiaohei = new Dog("xiaohei");
console.log(xiaohei.run());
console.log(xiaohei.bark());

// 类的多态
class Cat extends Animal {
  static categories = ["mammel"];
  constructor(name) {
    super(name);
    console.log(this.name);
  }
}
